home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / Signal.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-16  |  3.8 KB  |  184 lines

  1. /* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.1 $ */
  2. #if __SC__ || __RCC__
  3. #pragma once
  4. #endif
  5.  
  6. #ifndef __SIGNAL_H
  7. #define __SIGNAL_H 1
  8.  
  9. #if __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  14. #ifndef _CRTAPI1
  15. #define _CRTAPI1 __cdecl
  16. #endif
  17.  
  18. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  19. #ifndef _CRTAPI2
  20. #define _CRTAPI2 __cdecl
  21. #endif
  22.  
  23. /* Define CRTIMP */
  24. #ifndef _CRTIMP
  25. #if defined(_WIN32) && defined(_DLL)
  26. #define _CRTIMP  __declspec(dllimport)
  27. #else
  28. #define _CRTIMP
  29. #endif
  30. #endif
  31.  
  32. #if __OS2__ && __INTSIZE == 4
  33. #define __CLIB    __stdcall
  34. #else
  35. #define __CLIB    __cdecl
  36. #endif
  37.  
  38. typedef volatile int sig_atomic_t;
  39.  
  40. void (__CLIB * __CLIB signal(int,void (__CLIB *)(int)))(int);
  41.  
  42. #if M_UNIX || M_XENIX
  43. #define SIGHUP     1
  44. #define SIGINT     2
  45. #define SIGQUIT     3
  46. #define SIGILL     4
  47. #define SIGTRAP     5
  48. #define SIGIOT     6
  49. #define SIGABRT     6
  50. #define SIGEMT     7
  51. #define SIGFPE     8
  52. #define SIGKILL     9
  53. #define SIGBUS     10
  54. #define SIGSEGV     11
  55. #define SIGSYS     12
  56. #define SIGPIPE     13
  57. #define SIGALRM     14
  58. #define SIGTERM     15
  59. #define SIGUSR1     16
  60. #define SIGUSR2     17
  61. #define SIGCLD     18
  62. #define SIGPWR     19
  63. #define SIGWINCH 20
  64.  
  65. #if M_XOUT
  66. #define SIGPOLL 20
  67. #else
  68. #define SIGPOLL 22
  69. #endif
  70.  
  71. #define SIGCHLD SIGCLD
  72.  
  73. #if M_UNIX
  74. #define SIGURG  21
  75. #define SIGSTOP 23
  76. #define SIGTSTP 24
  77. #define SIGCONT 25
  78. #define SIGTTIN 26
  79. #define SIGTTOU 27
  80. #define SIGVTALRM 28
  81. #define SIGPROF 29
  82. #define SIGXCPU 30
  83. #define SIGXFSZ 31
  84. #define _NSIG    32
  85. #else
  86. #define _NSIG    21
  87. #endif /* M_UNIX */
  88.  
  89. #if !__STDC__
  90. #define NSIG _NSIG
  91. #endif
  92.  
  93. #if !__STDC__ || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  94. #include <sys/types.h>
  95. typedef long    sigset_t;
  96.  
  97. #define SIGALL (~(sigset_t)0L) /* All signals.    */
  98.  
  99. #define sigbit(n)    (1L << ((n) - 1))
  100. #define sigemptyset(s)    *(s) = ~SIGALL
  101. #define sigfillset(s)    *(s) = SIGALL
  102. #if 0
  103. #define sigaddset(s,n)  *(s) |= sigbit(n)
  104. #define sigdelset(s,n)  *(s) &= ~sigbit(n)
  105. #define sigismember(set,n) ((*(set) & sigbit(n)) == sigbit(n))
  106. #else
  107. int __CLIB sigaddset(sigset_t *,int);
  108. int __CLIB sigdelset(sigset_t *,int);
  109. int __CLIB sigismember(const sigset_t *,int);
  110. #endif
  111. int __CLIB sigpending(sigset_t *);
  112. int __CLIB sigprocmask(int, const sigset_t *, sigset_t *);
  113. int __CLIB sigsuspend(const sigset_t *);
  114.  
  115. struct  sigaction
  116.         {
  117.         void    (*sa_handler)(int);
  118.         sigset_t sa_mask;
  119.         int     sa_flags;
  120.         };
  121.  
  122. int __CLIB sigaction(int sig, const struct sigaction *act,
  123.                                      const struct sigaction *oact);
  124. int __CLIB kill(pid_t,int);
  125. pid_t __CLIB getpid(void);
  126.  
  127. #define SA_NOCLDSTOP    1
  128.  
  129. #define SIG_BLOCK       1
  130. #ifdef M_ELF
  131. #define SIG_SETMASK     3
  132. #else
  133. #define SIG_SETMASK     0
  134. #endif
  135. #define SIG_UNBLOCK     2
  136.  
  137. #endif
  138.  
  139. #define SIG_ERR  (void(__CLIB *)(int))-1
  140. #define SIG_DFL  (void(__CLIB *)(int))0
  141. #define SIG_IGN  (void(__CLIB *)(int))1
  142. #define SIG_HOLD (void(__CLIB *)(int))2
  143.  
  144. int __CLIB pause(void);
  145. unsigned int __CLIB alarm(unsigned int seconds);
  146.  
  147. #else /* M_UNIX || M_XENIX */
  148.  
  149.  
  150. #define _NSIG 23 /* = SIGABRT + 1 */
  151.  
  152. #if !__STDC__
  153. #define NSIG _NSIG
  154. #endif
  155.  
  156. #define SIGINT    2        /* interrupt            */
  157. #define SIGILL    4        /* illegal instruction        */
  158. #define SIGFPE    8        /* floating point error        */
  159. #define SIGSEGV 11        /* segment violation        */
  160. #define SIGTERM 15        /* terminate            */
  161.  
  162. #if _WIN32
  163. #define SIGBREAK 21        /* ctrl-break under NT        */
  164. #else
  165. #define SIGBREAK  SIGINT  /* Under DOS, SIGBREAK is SIGINT */
  166. #endif
  167.  
  168. #define SIGABRT 22        /* abort            */
  169.  
  170.  
  171. #define SIG_DFL        (void (__CLIB *)(int)) 0
  172. #define SIG_ERR        (void (__CLIB *)(int)) -1
  173. #define SIG_IGN        (void (__CLIB *)(int)) 1
  174.  
  175. #endif
  176.  
  177. int __CLIB raise(int);
  178.  
  179. #if __cplusplus
  180. }
  181. #endif
  182.  
  183. #endif
  184.